package com.example.stock.service.impl;

import com.example.stock.mapper.WeekDetailMapper;
import com.example.stock.model.WeekDetail;
import com.example.stock.service.LevelPointService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Comparator;
import java.util.List;

@Service
public class LevelPointServiceImpl implements LevelPointService {

    @Autowired
    WeekDetailMapper weekDetailMapper;

    @Override
    public List<WeekDetail> getByWeekAndLp(String week, int lp) {
        List<WeekDetail> weekDetailByDate = weekDetailMapper.getWeekDetailByDate(week);
        return weekDetailByDate.stream()
                .filter(weekDetail -> weekDetail.getLp() >= lp)
                .filter(weekDetail -> weekDetail.getLp() < (lp + 20))
                .sorted(Comparator.comparing(WeekDetail::getLp)).toList();
    }
}